package com.qyhl.webtv.commonlib.item;

import android.view.View;
import android.widget.TextView;

import com.qyhl.webtv.basiclib.utils.StringUtils;
import com.qyhl.webtv.commonlib.R;
import com.qyhl.webtv.commonlib.entity.news.GlobalNewsBean;
import com.zhy.adapter.recyclerview.base.ItemViewDelegate;
import com.zhy.adapter.recyclerview.base.ViewHolder;

/**
 * Created by qyhl on 2018/4/20.
 * 报料
 */

public class ItemScoop implements ItemViewDelegate<GlobalNewsBean> {

    public ItemScoop() {
    }

    @Override
    public int getItemViewLayoutId() {
        return R.layout.news_item_newslist_scoop;
    }

    @Override
    public boolean isForViewType(GlobalNewsBean item, int position) {
        return "18".equals(item.getType());
    }

    @Override
    public void convert(ViewHolder holder, GlobalNewsBean bean, int position) {
        TextView title = holder.getView(R.id.title);
        title.setText(bean.getTitle());

        TextView content = holder.getView(R.id.content);
        if (StringUtils.isNotEmpty(bean.getCatalogId())) {
            content.setVisibility(View.VISIBLE);
            content.setText(bean.getCatalogId());
        } else {
            content.setVisibility(View.GONE);
        }


        TextView topicName = holder.getView(R.id.topic_name);
        if (StringUtils.isNotEmpty(bean.getOrigin())) {
            topicName.setVisibility(View.VISIBLE);
            topicName.setText("#" + bean.getOrigin() + "#");
        } else {
            topicName.setVisibility(View.GONE);
        }


        TextView status = holder.getView(R.id.status);
        status.setVisibility(View.VISIBLE);
        switch (bean.getLivetype()) {
            case "2":
                status.setText("未处理");
                break;
            case "21":
                status.setText("处理中");
                break;
            case "22":
                status.setText("已处理");
                break;
            default:
                status.setVisibility(View.GONE);
                break;
        }
    }
}
